home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
presto
/
presto10.lha
/
src
/
unix_timer.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-11
|
677b
|
54 lines
/*
* Unix support for timer object.
*
*/
#include <stddef.h>
#include <time.h>
#include "presto.h"
void
Timer::init()
{
t_starttime = getabsolutetime();
}
Timer::~Timer()
{
}
double
Timer::getabsolutetime()
{
struct timeval *t_tv;
t_tv = getdaytime();
return (double)t_tv->tv_sec +
((double)(t_tv->tv_usec) * 1.0e-6);
}
char*
Timer::getasciitime()
{
struct timeval *t_tv;
t_tv = getdaytime();
return ctime((time_t *)&t_tv->tv_sec);
}
struct timeval*
Timer::getdaytime()
{
gettimeofday(&t_time,(struct timezone *)0);
return &t_time;
}
void
Timer::print(ostream& s)
{
s << form("(Timer)this= 0x%x,", this) <<
"t_starttime = " << t_starttime;
}